package com.muyu.common.core.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author Administrator
 */


@AllArgsConstructor
@Getter
public enum OrderStatus {
    PAY_PENDING(1, "支付进行中"),
    TO_BE_SHIPPED(2, "待发货"),
    TO_BE_RECEIVED(3, "待收货"),
    TO_BE_EVALUATED(4, "待评价"),
    AFTER_SALES(5, "售后中"),
    SUCCESS(6, "交易成功"),
    CLOSE(7, "交易关闭"),
    REFUND_SUCCESS(8, "退款成功"),
    REFUND_PENDING(9, "退款进行中"),
    REFUND_FAILED(10, "退款失败"),
    REJECTED(11, "已驳回");

    @EnumValue
    private final int code;

    private final String name;

    @JsonValue
    public int getCode() {
        return code;
    }

    @JsonCreator
    public static OrderStatus getByCode(int code) {
        for (OrderStatus status : values()) {
            if (status.getCode() == code) {
                return status;
            }
        }
        return null;
    }
}
